package inter

import (
	"fmt"
	"strconv"
)

// func main() {
// 	var phone Phone
// 	phone = new(Huawei)
// 	phone.call()
// 	fmt.Println(phone.priceDesc())

// 	phone = Xiaomi{name: "小米", price: 1000}
// 	phone.call()
// 	fmt.Println(phone.priceDesc())

// }

/**
 * 定义接口
 */
type Phone interface {
	/*
	 * 打电话
	 */
	call()

	/**
	 * 价格
	 */
	priceDesc() string
}

/**
 * 定义结构体
 */
type Huawei struct {
	price int
	name  string
}

type Xiaomi struct {
	price int
	name  string
}

/**
 * 实现类华为
 */
func (huawei Huawei) call() {
	fmt.Println("use huawei phone call")
}

func (huawei Huawei) priceDesc() string {
	return huawei.name + "的价格是" + strconv.Itoa(huawei.price) + "元"
}
func (xiaomi Xiaomi) call() {
	fmt.Println("use xiaomi phone call")
}
func (xiaomi Xiaomi) priceDesc() string {
	return xiaomi.name + "的价格是" + strconv.Itoa(xiaomi.price) + "元"
}

// func calculateAllPrice(phones []Phone) int {
// 	var totalPrice int
// 	for _,phone := range phones {
// 		totalPrice += phone.priceDesc()
// 	}
// }
